package com.hong.base.structure_type_model.proxymodel.car.dynamic_proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @Auther: csh
 * @Date: 2020/6/2 16:22
 * @Description:代理(Proxy)
 */
public class ProHandler implements InvocationHandler {

    Object obj = null;


    public ProHandler(Object obj) {
        this.obj = obj;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("我是代理，正在驾驶");
        Object invoke = method.invoke(obj, args);
        System.out.println("到达目的地");
        return invoke;
    }
}
